package com.fisicaapp;

class Cinematica{

	protected VectorMath posicion;
	protected VectorMath velocidad;
	protected double tiempo;
	protected double Xo, Yo, Vox, Voy, angle;

	public static final double dt = 0.01; //precision
	public static double Ax, Ay; //aceleracion en X e Y


// se extiende a Mov Circular Uniforme
	public Cinematica(double Xo, double Yo, double Vo, double angle,double Ax, double Ay, int ancho, int alto){
		this.Xo = Xo;
		this.Yo = -(Yo - alto);
		this.Vox = Vo*Math.cos(angle);
		this.Voy = Vo*Math.sin(angle);
		this.Ax = Ax;
		this.Ay = Ay;
		this.angle = angle;
		this.posicion = new VectorMath(this.Xo,this.Yo);
		this.posicion.setOrigen2(0, alto);
		this.velocidad = new VectorMath(this.Vox, this.Voy);
		this.velocidad.setOrigen2(0, alto);
		
		tiempo = 0;
		
		
	}

	public VectorMath getPosicion(){ return posicion; }		
	public VectorMath getVelocidad(){ return velocidad; }	
	public double getTiempo(){ return tiempo; }

	public void setAx(double Ax){ this.Ax = Ax;	}
	public void setAy(double Ay){ this.Ay = Ay;	}	

	public void setTiempo(double t){
		tiempo = t;
		update(t);
	}
	
	private void update(double time){
		double x = Xo + Vox*time + Ax*(time*time)/2;
		double y = Yo + Voy*time + Ay*(time*time)/2;
		double vx = Vox + Ax*time;
		double vy = Voy + Ay*time;
		posicion.setXY(x,y,false);
		velocidad.setXY(vx,vy,false);


	}

	
	

}